<?php

use Biz\service\springHomeDecActivity\WishService;
use Biz\service\springHomeDecActivity\Util;

class LotteryRemindAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_REGISTER;

    const VALIDATOR_TOAST_DEBUG = true;

    //参数校验-规则
    public const VALIDATOR_RULES = [
        'wish_id' => 'require|integer',
        'lottery_remind' => 'require|integer',
    ];

    public function main()
    {
        $lockKey = 'spring_home_dec_act:lottery_remind:' . $this->uid;
        Util::lockSubmit($lockKey);

        $wish_id = $this->params['wish_id'] ?? 0;
        $lotteryRemind = $this->params['lottery_remind'] ?? 0;
        $nResult = WishService::LotteryRemind($this->uid,$wish_id,$lotteryRemind);
        if(!$nResult){
            throw new Exception('设置抽奖提醒失败',self::CODE_ERROR_VIEW_TOSTA);
        }
        $this->setSuccess('success');
    }
}